﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="CodeDemon.Views.Review.Index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    
<h2>Reviews That Need Your Input</h2>

<a id="show"><img id="arrow" src="/CodeDemon/Content/arrow_closed.gif" border="0" />&nbsp;&nbsp;Show Search Parameters</a>
<a  style="display:none;" id="hide"><img id="arrow2" src="/CodeDemon/Content/arrow_open.gif" border="0" />&nbsp;&nbsp;Show Search Parameters</a> 

<div id="FilterSection" style="display:none;">
<form action="/CodeDemon/Review/Index" method="post" id="htmlForm">

    <%
        var sl = from statusList in ViewData.Model.DAO.ReviewStatus select statusList;
         %>
         
         Filter: <select name="statusId">
         <% foreach (var s in sl) { %>
            <option value="<%= s.ReviewStatusID %>"><%=s.StatusName %></option>
            <% } %>
         </select>        <input type="submit" name="Submit" value="Apply Filter" />

<%= Html.Hidden("ReviewId", ViewData.Model.CurrentReviewID.ToString())%>
</p>

<script type="text/javascript">
             $('#show' ).click(function() {
                    $('#FilterSection' ).show('1');
                    $('#show' ).hide();
                    $('#hide' ).show();
             });
             $('#hide' ).click(function() {
                    $('#FilterSection' ).hide('1');
                    $('#show' ).show();
                    $('#hide' ).hide();
             });
</script>

</form>
</div>

<% 
    var r = from reviews in ViewData.Model.DAO.Reviews
            join status in ViewData.Model.DAO.ReviewStatus on reviews.ReviewStatusID equals status.ReviewStatusID
            join parts in ViewData.Model.DAO.ReviewParticipants on reviews.ReviewID equals parts.ReviewID
            join partStatus in ViewData.Model.DAO.ReviewStatus on parts.ReviewStatusID equals partStatus.ReviewStatusID
            where reviews.ReviewStatusID == ViewData.Model.SelectedStatusIdForList
			&& parts.ReviewUserID == ViewData.Model.CurrentReviewUserID
			&& parts.ParticipantIsReviewer == true
			&& partStatus.IsFinishedStatus == false
            orderby reviews.ReviewCreatedTimeStamp descending
            select new
            {
                reviews.ReviewID,
                reviews.Title,
                reviews.Description,
                status.StatusName,
                reviews.ReviewCreatedTimeStamp,
                reviews.DefectNumber
            };

    Response.Write( "<table class='tablesorter' id='myTable'><thead><tr><th nowrap='true'>Title</th><th>Description</th><th width='10%'>Status</th><th width='6%'>ReviewID</th><th nowrap='true' width='6%'>Defect ID</th><th nowrap='true' width='8%'>Timestamp</th></tr></thead><tbody>" ); 
       foreach(var review in r ) {

           Response.Write(String.Format("<tr><td>{0}</td>", Html.ActionLink(review.Title, "DisplayReview", "Review", new {reviewId = review.ReviewID}, null)));
           Response.Write( String.Format( "<td>{1}</td><td>{2}</td><td>{3}</td><td><a href='{6}{4}'>{4}</a></td><td>{5}</td></tr>", review.Title, review.Description, review.StatusName, review.ReviewID, review.DefectNumber, review.ReviewCreatedTimeStamp, ConfigurationManager.AppSettings["DefectSystem_LookupURL"] ) );
       }
    Response.Write("</tbody></table>");
    %>

<h2>Reviews On Which You are an Auxillery Participant</h2>
<% 
    var h = from reviews in ViewData.Model.DAO.Reviews
            join status in ViewData.Model.DAO.ReviewStatus on reviews.ReviewStatusID equals status.ReviewStatusID
            join parts in ViewData.Model.DAO.ReviewParticipants on reviews.ReviewID equals parts.ReviewID
            where reviews.ReviewStatusID == ViewData.Model.SelectedStatusIdForList
			&& parts.ReviewUserID == ViewData.Model.CurrentReviewUserID
            && parts.ParticipantIsReviewer == false
            orderby reviews.ReviewCreatedTimeStamp descending
            select new
            {
                reviews.ReviewID,
                reviews.Title,
                reviews.Description,
                status.StatusName,
                reviews.ReviewCreatedTimeStamp,
                reviews.DefectNumber
            };

    Response.Write( "<table class='tablesorter' id='myTable3'><thead><tr><th nowrap='true'>Title</th><th>Description</th><th width='10%'>Status</th><th width='6%'>ReviewID</th><th nowrap='true' width='6%'>Defect ID</th><th nowrap='true' width='8%'>Timestamp</th></tr></thead><tbody>" ); 
       foreach(var review in h ) {

           Response.Write(String.Format("<tr><td>{0}</td>", Html.ActionLink(review.Title, "DisplayReview", "Review", new {reviewId = review.ReviewID}, null)));
           Response.Write( String.Format( "<td>{1}</td><td>{2}</td><td>{3}</td><td><a href='{6}{4}'>{4}</a></td><td>{5}</td></tr>", review.Title, review.Description, review.StatusName, review.ReviewID, review.DefectNumber, review.ReviewCreatedTimeStamp, ConfigurationManager.AppSettings["DefectSystem_LookupURL"] ) );
       }
    Response.Write("</tbody></table>");
    %>

<h2>Reviews You Created</h2>
<% 
    var q = from reviews in ViewData.Model.DAO.Reviews
            join status in ViewData.Model.DAO.ReviewStatus on reviews.ReviewStatusID equals status.ReviewStatusID
            where reviews.ReviewStatusID == ViewData.Model.SelectedStatusIdForList && reviews.ReviewOwnerID == ViewData.Model.CurrentReviewUserID
            orderby reviews.ReviewCreatedTimeStamp descending
            select new
            {
                reviews.ReviewID,
                reviews.Title,
                reviews.Description,
                status.StatusName,
                reviews.ReviewCreatedTimeStamp,
                reviews.DefectNumber
            };

    Response.Write( "<table class='tablesorter' id='myTable2'><thead><tr><th>Title</th><th>Description</th><th width='10%'>Status</th><th width='6%'>ReviewID</th><th nowrap='true' width='6%'>Defect ID</th><th nowrap='true' width='8%'>Timestamp</th></tr></thead><tbody>" ); 
       foreach(var review in q ) {

           Response.Write(String.Format("<tr><td>{0}</td>", Html.ActionLink(review.Title, "DisplayReview", "Review", new {reviewId = review.ReviewID}, null)));
           Response.Write( String.Format( "<td>{1}</td><td>{2}</td><td>{3}</td><td><a href='{6}{4}'>{4}</a></td><td>{5}</td></tr>", review.Title, review.Description, review.StatusName, review.ReviewID, review.DefectNumber, review.ReviewCreatedTimeStamp, ConfigurationManager.AppSettings["DefectSystem_LookupURL"] ) );
       }
    Response.Write("</tbody></table>");
    %>

    <script type="text/javascript">
        $(document).ready(function() 
        { 
             $("#myTable").tablesorter({widthFixed: true, widgets: ['zebra']});  
             $("#myTable2").tablesorter({widthFixed: true, widgets: ['zebra']});  
             $("#myTable3").tablesorter({widthFixed: true, widgets: ['zebra']});  
        } ); 
    </script>

</asp:Content>
